/**
  * @Description: WoShop商城
  * @Author: 梧桐
  * @Copyright: 武汉一一零七科技有限公司©版权所有
  * @Link: www.s1107.com
  * @Contact: QQ:2487937004
  */
 <template>
    <view class="page">
  
      <u-steps class="u-m-" :list="numList" :current="Number(applys.zhuangtai)-1" mode="number" active-color="#ffc107"></u-steps>
      
        <view class="settled u-p-25" v-if="applys.zhuangtai == 6">
            <p  >拒绝原因:{{applys.remarks}}</p>
            <u-button type="warning"   @click="$u.route(`/pagesB/applyShop/applyShop?typeshop=1`)">重新申请入驻</u-button>
         
        </view>


      <p class="u-p-25">{{applys.xinxi}}</p>
      
      <u-cell-group v-if="applys.zhuangtai == 3">
        <u-cell-item  title="您申请的行业为" :value="industrys.industry_name" :arrow="false"></u-cell-item>
        <u-cell-item title="费率"  :value="industrys.remind /100 +'%'" :arrow="false"></u-cell-item>
        <u-cell-item  title="缴纳的保证金"    :value="'¥'+industrys.ser_price" :arrow="false"></u-cell-item>
        <u-button class="u-m-20" @click="openPayPop" type="warning" >缴纳保证金</u-button>
      </u-cell-group>
      <p class="u-p-25" style="color:#999">如果状态未能实时变更，可下拉刷新获取实时信息变更</p>
<!--      收银台组件-->
          <payPop ref="payPop" :totalPrice="industrys.ser_price">
             <div  class="pay-btn" @click="$u.debounce(crosspay,1500)">确认支付</div>
          </payPop >


    </view>
</template>

<script>

let providerList = []
import payPop from "../../components/payPop";

export default {
    components:{
      payPop
    },


    data(){
        return {
            applys:{},
            industrys:{},
            isPayPopShow:false,

        }
    },
  computed:{
    numList(){
      return [
        {
          name:'申请'
        },  {
          name:'等待审核'
        },  {
          name:'缴纳保证金'
        },  {
          name:'等待开通'
        },  {
          name:'成功开通'
        },
      ]
    }
  },
  onLoad(){
    uni.setNavigationBarTitle({
      title: '入驻流程'
    });
  },
  onShow(){
      this.getapplystatus()
  },
  onPullDownRefresh(){
        this.getapplystatus()
  },
    methods: {
        getapplystatus(){
            this.$http.getapplystatus().then(res=>{
                if(res.status == 200) {
                    this.applys = res.data
                    this.industrys = res.data.industrys
                  this.$refs.payPop.payModel = false
                     uni.stopPullDownRefresh()
                }
            })
        },
     openPayPop(){
       this.$refs.payPop.payModel = true;
      },
       async  crosspay(){
            const ref = this.$refs.payPop
            let orderInfo;
            try{
             orderInfo = await this.getorderzhifu(ref.payType);
            }catch(e){
              this.$toast('支付失败')
            }
            console.log("-> orderInfo", orderInfo);
            ref.payinfos = await orderInfo.data.infos
            ref.crosspay()
            this.$refs.payPop.payModel = false;
          },
        /**
         * 支付保证金
         */
        getorderzhifu(type){
          let wechat_miniprogram;
          // #ifndef MP-WEIXIN
          wechat_miniprogram = 0;
          // #endif
          // #ifdef MP-WEIXIN
           wechat_miniprogram = 1;
          // #endif
          const data ={
            zf_type:type,
            wechat_miniprogram,
            xcx_openid:uni.getStorageSync('xcxOpenid')
          }
           return new Promise((resolve,reject)=>{
             this.$http.getorderzhifu(data).then(res=>{
               if(res.status == 200) {
                  resolve(res)
               }else{
                 reject(res)
               }
             })
           })
         
        },

    },
}
</script>

<style lang="scss" scoped>
.page{
  background-color: #fff;
  padding-top:30upx;
}
.sett-status {
    padding-left: 30upx;
    margin-top: 30upx;

    font-size: 26upx;
}
.u-p-25{
  padding: 25upx;
}
.u-m-20{
  margin: 20upx;
}

.settled {
  background-color:#fff;
  padding: 17upx 0 30upx 0;
  margin: 20upx 0;
  .son {
    color: #FA3F3F;
    font-size: 28upx;
    padding-left: 24upx;
    display: flex;
  }
  .son-list {
    height: 98upx;
    line-height: 98upx;
    color: #333;
    font-size: 28upx;
    padding: 0 24upx;
    border-bottom: 1upx solid rgba(249,249,249,1);
  }
}
</style>
